using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
namespace BUS
{
    public class UserBUS
    {
        public static void Insert(tbUser user)
        {
            UserDAL userdal = new UserDAL();
            userdal.Insert(user);
        }
        public static void Update(tbUser user)
        {
            UserDAL userdal = new UserDAL();
            userdal.Update(user);
        }
        public static void Delete(int iD)
        {
            UserDAL userdal = new UserDAL();
            userdal.Delete(iD);
        }
        public static tbuserColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            UserDAL userdal = new UserDAL();
            return userdal.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbUser GetByID(int iD)
        {
            int t = 0;
            UserDAL userdal = new UserDAL();
            tbuserColection usercolection = userdal.GET("where " + tbuserColumn.iduser.ToString() + " = " + iD.ToString(), 0, 0,
                tbuserColumn.ten.ToString(), "ASC", out t);
            if (usercolection.Count == 1)
                return usercolection[0];
            return null;
        }
        public static tbuserColection GetAll()
        {
            int t = 0;
            UserDAL userdal = new UserDAL();
            return userdal.GET("where 1=1", 0, 10,
                tbuserColumn.ten.ToString(), "ASC", out t);
        }
       
    }
}
